<?php

class functions {

    /*
     * Transforme une Date Time en une date sous Format MySQL (Y-m-d H:i:s)
     */
    function phpToMysqlDatetime ($datetime) {
		$newDate = str_replace ("/", "-", $datetime);
        $tmpDate = new DateTime($newDate);
        return date_format($tmpDate, "Y-m-d H:i:s");
    }

    /*
     * Transforme une Date en une date sous Format MySQL (Y-m-d)
     */
    function phpToMysqlDate ($date) {
		$newDate = str_replace ("/", "-", $date);
        $tmpDate = new DateTime($newDate);
        return date_format($tmpDate, "Y-m-d");
    }
	
	function age($date_naissance) {
		$am = explode('/', $date_naissance);
		$an = explode('/', date('d/m/Y'));
	 
		if(($am[1] < $an[1]) || (($am[1] == $an[1]) && ($am[0] <= $an[0]))) {
			return $an[2] - $am[2];
		}
	 
		return $an[2] - $am[2] - 1;
	}
}
?>
